package com.zmm.util.auth.filter;

import com.zmm.util.auth.model.AuthParam;
import com.zmm.util.auth.registry.annotation.AuthAnonymous;
import org.springframework.web.method.HandlerMethod;

/**
 * @author 900045
 * @description:
 * @name AnonymousFilter
 * @date By 2021-07-06 09:29:52
 */
public class AnonymousFilter implements AuthFilter {


	@Override
	public boolean doFilter(HandlerMethod handler, AuthParam param) {
		//1.查看类上是否有加匿名类
		AuthAnonymous annotation = handler.getBeanType().getAnnotation(AuthAnonymous.class);
		if (annotation == null) {
			//2.查看方法是否有匿名类
			param.setCanAnon(handler.hasMethodAnnotation(AuthAnonymous.class));
		} else {
			param.setCanAnon(true);
		}
		//不管有没有匿名类  都要返回true
		return true;
	}
}
